In computer programming, event-driven or event-based programming is a programming model in which program flow is determined by events. An event is an action initiated either by a user, a device such as a timer or keyboard, or by the operating system. When an event occurs (fires), data about the event is typically collected by a piece of hardware or software which typically dispatches the event to an event handler, an asynchronous callback subroutine, for further processing. The data associated with an event and sent to the event handler specifies what type of event has fired and may include information such as when the event occurred, who or what caused the event to occur, and how the event should be processed.
A program that changes its behavior in response to events is said to be event-driven. Many interactive programs are event-driven. Event-driven programs can be written in any language, although are easier to write in languages that provide high-level abstractions to support events and event handling. Some integrated development environments provide code generation assistants that automate the most repetitive tasks associated with event handling.